
import { words } from '../../.internal/lodash/words.js';
import { toString } from '../../.internal/lodash/toString.js';

/**
 * @desc    转换字符串string为kebab case。
 * @param   {[string='']} string 要转换的字符串
 * @return  {String} 返回烤肉串写法的字符串
 */
const kebabCase = (string) =>
	words(toString(string).replace(/['\u2019]/g, '')).reduce(
		(result, word, index) => result + (index ? '-' : '') + word.toLowerCase(),
		'',
	);

export { kebabCase };